﻿#If (Not WINDOWS_PHONE) And (Not NETFX_CORE) Then

Imports Microsoft.Xna.Framework.Audio
Imports Microsoft.Xna.Framework.Graphics
Imports System.Runtime.CompilerServices
Imports System.IO
Imports Runa.Common.Helper

Namespace Global.Runa.Resources.ContentManagers

    Public Class StreamContentManager
        Inherits BasicContentManager

        Private m_stream As Stream

        Public Sub New(serviceProvider As System.IServiceProvider)
            MyBase.New(serviceProvider)
        End Sub

        Public Overloads Function Load(Of T)(ByVal s As Stream) As T
            Me.m_stream = s
            Dim res = MyBase.Load(Of T)(s.ToString())
            s.Dispose()
            Return res
        End Function

        Public Overrides Function Exists(ByVal assetName As String) As Boolean
            Throw New NotImplementedException("StreamContentManager.Exists")
        End Function

        Protected Overrides Function OpenStream(assetName As String) As System.IO.Stream
            If Me.m_stream IsNot Nothing Then
                Return Me.m_stream
            End If
            Throw New ArgumentException("Invalid stream is provided.")
        End Function

    End Class

End Namespace

#End If